package models

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Mobile     string `gorm:"type:char(11);unique;not null;comment:账号"`
	Password   string `gorm:"type:char(32);not null;comment:密码"`
	MemberTime int    `gorm:"type:int(11);comment:会员到期时间"`
}

func (u *User) ShowUser() error {
	return DB.Debug().Where("mobile = ?", u.Mobile).Find(&u).Error
}

func (u *User) ShowUserById() error {
	return DB.Debug().Where("id = ?", u.ID).Find(&u).Error
}

func (u *User) Redister() error {
	return DB.Debug().Create(&u).Error
}
